function WallJump(ply, key)	
	if !ply:KeyDown(IN_JUMP) then return end
	if (CurTime() < ply.WalljumpTimer) then return end
	ReboundPower = 300
	ReboundPowerUp = 180
	local tr = 	util.TraceLine(util.GetPlayerTrace(ply, Vector(0, 0, -1)))
	if !tr.Hit then return end
	local HitDistance = tr.HitPos:Distance(tr.StartPos)
	if (HitDistance > 8) then
		local vForward = ply:GetForward():GetNormalized()
		local vRight = ply:GetRight():GetNormalized()
		local vVelocity = Vector(0,0,0)
		local pVelocity = ply:GetVelocity()
		--if (pVelocity.z < 0) then return end
		if ply:KeyDown(IN_MOVERIGHT) then
			local tracedata = {}
			tracedata.start = ply:GetPos()
			tracedata.endpos = ply:GetPos()+(vRight*-24)
			tracedata.filter = ply
			local tr = util.TraceLine(tracedata)
			if (tr.Fraction < 1.0) then
				vVelocity = pVelocity + (vRight * ReboundPower)
				vVelocity.z = pVelocity.z + ReboundPowerUp
				ply:SetLocalVelocity(vVelocity)
				WallJumpSound(ply)
				ply.WalljumpTimer = CurTime() + WALLJUMPTIME + ply.WalljumpCombo * WALLJUMPDECAY
			end
		end
		if ply:KeyDown(IN_MOVELEFT) then
			local tracedata = {}
			tracedata.start = ply:GetPos()
			tracedata.endpos = ply:GetPos()+(vRight*24)
			tracedata.filter = ply
			local tr = util.TraceLine(tracedata)
			if (tr.Fraction < 1.0) then
				vVelocity = pVelocity + (vRight * -ReboundPower)
				vVelocity.z = pVelocity.z + ReboundPowerUp
				ply:SetLocalVelocity(vVelocity)
				WallJumpSound(ply)
				ply.WalljumpTimer = CurTime() + WALLJUMPTIME + ply.WalljumpCombo * WALLJUMPDECAY
			end
		end
		if ply:KeyDown(IN_BACK) then
			local tracedata = {}
			tracedata.start = ply:GetPos()
			tracedata.endpos = ply:GetPos()+(vForward*24)
			tracedata.filter = ply
			local tr = util.TraceLine(tracedata)
			if (tr.Fraction < 1.0) then
				vVelocity = pVelocity + (vForward * -ReboundPower)
				vVelocity.z = pVelocity.z + ReboundPowerUp
				ply:SetLocalVelocity(vVelocity)
				WallJumpSound(ply)
				ply.WalljumpTimer = CurTime() + WALLJUMPTIME + ply.WalljumpCombo * WALLJUMPDECAY
			end
		end
		if ply:KeyDown(IN_FORWARD) then
			local tracedata = {}
			tracedata.start = ply:GetPos()
			tracedata.endpos = ply:GetPos()+(vForward*-24)
			tracedata.filter = ply
			local tr = util.TraceLine(tracedata)
			if (tr.Fraction < 1.0) then
				vVelocity = pVelocity + (vForward * ReboundPower)
				vVelocity.z = pVelocity.z + ReboundPowerUp
				ply:SetLocalVelocity(vVelocity)
				WallJumpSound(ply)
				ply.WalljumpTimer = CurTime() + WALLJUMPTIME + ply.WalljumpCombo * WALLJUMPDECAY
			end
		end
	end
end
hook.Add("KeyPress", "WallJump", WallJump)

function WallJumpSound(ply)
	ply:EmitSound("/physics/concrete/rock_impact_hard" .. math.random(1, 6) .. ".wav", math.Rand(90, 110), math.Rand(60, 80))
	WallJumpCombo(ply)
end

function WallJumpCombo(ply)
	ply.WalljumpCombo = ply.WalljumpCombo + 1
end
